//auto gen by paipai.java.augogen ver 3.0.0
//author skyzhuang
//source idl: com.icson.deal.idl.ShoppingCartDao.java


#ifndef ICSON_DEAL_SHOPPINGCART_BO_CSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H
#define ICSON_DEAL_SHOPPINGCART_BO_CSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H


#include "app_platform/intf_serializable.h"
#include <map>
#include "icson/deal/shoppingcart/bo/shoppingcartproduct_deal.h"
#include <string>
#include <sstream>
#include <iostream>


namespace icson
{
namespace deal
{
namespace shoppingcart
{
namespace bo
{


class CShoppingcartObject : public ISerializable
{
	public:
		std::string m_sLastErrMsg;///<错误信息

		/**
		 * 协议版本号
		 *
		 * 版本 >= 0
		 */
		uint32_t dwVersion;

		/**
		 * 版本 >= 0
		 */
		uint8_t cVersion_u;

		/**
		 * 用户易迅ID
		 *
		 * 版本 >= 0
		 */
		uint64_t ddwUserId;

		/**
		 * 版本 >= 0
		 */
		uint8_t cUserId_u;

		/**
		 * 商品列表
		 *
		 * 版本 >= 0
		 */
		std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct>  mapProductList;

		/**
		 * 版本 >= 0
		 */
		uint8_t cProductList_u;




	public:
		CShoppingcartObject():
		dwVersion(0),
		cVersion_u(0),
		ddwUserId(0),
		cUserId_u(0),
		cProductList_u(0) {}
				CShoppingcartObject& operator = (const CShoppingcartObject& obj){

			this->dwVersion = obj.dwVersion;
			this->cVersion_u = obj.cVersion_u;
			this->ddwUserId = obj.ddwUserId;
			this->cUserId_u = obj.cUserId_u;
			this->mapProductList = obj.mapProductList;
			this->cProductList_u = obj.cProductList_u;
			return *this;
		}

	public:


		/**
		 * 是否设置协议版本号了
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 bool  IsVersionSet() const{
				 return  cVersion_u != 0;
		}


		/**
		 * 获取uflag协议版本号了
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 const uint8_t   GetVersionUFlag() const{
				 return  cVersion_u;
		}


		/**
		 * 设置协议版本号
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 void  SetVersion( const uint32_t& sVal, uint8_t cUFlag=1){
				dwVersion = sVal;
				cVersion_u = cUFlag;
		}


		/**
		 * 获取协议版本号
		 * 
		 * @return dwVersion value 类型为:uint32_t
		 * 
		 */
		 const uint32_t&  GetVersion() const {
				return dwVersion;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cVersion_u
		 *  
		 * 
		 */
		 void  SetVersion_u( const uint8_t& sVal){
				cVersion_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cVersion_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetVersion_u() const {
				return cVersion_u;
		}


		/**
		 * 是否设置用户易迅ID了
		 * 
		 * @param uint64_t:ddwUserId
		 *  
		 * 
		 */
		 bool  IsUserIdSet() const{
				 return  cUserId_u != 0;
		}


		/**
		 * 获取uflag用户易迅ID了
		 * 
		 * @param uint64_t:ddwUserId
		 *  
		 * 
		 */
		 const uint8_t   GetUserIdUFlag() const{
				 return  cUserId_u;
		}


		/**
		 * 设置用户易迅ID
		 * 
		 * @param uint64_t:ddwUserId
		 *  
		 * 
		 */
		 void  SetUserId( const uint64_t& sVal, uint8_t cUFlag=1){
				ddwUserId = sVal;
				cUserId_u = cUFlag;
		}


		/**
		 * 获取用户易迅ID
		 * 
		 * @return ddwUserId value 类型为:uint64_t
		 * 
		 */
		 const uint64_t&  GetUserId() const {
				return ddwUserId;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cUserId_u
		 *  
		 * 
		 */
		 void  SetUserId_u( const uint8_t& sVal){
				cUserId_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cUserId_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetUserId_u() const {
				return cUserId_u;
		}


		/**
		 * 是否设置商品列表了
		 * 
		 * @param std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> :mapProductList
		 *  
		 * 
		 */
		 bool  IsProductListSet() const{
				 return  cProductList_u != 0;
		}


		/**
		 * 获取uflag商品列表了
		 * 
		 * @param std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> :mapProductList
		 *  
		 * 
		 */
		 const uint8_t   GetProductListUFlag() const{
				 return  cProductList_u;
		}


		/**
		 * 设置商品列表
		 * 
		 * @param std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> :mapProductList
		 *  
		 * 
		 */
		 void  SetProductList( const std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> & sVal, uint8_t cUFlag=1){
				mapProductList = sVal;
				cProductList_u = cUFlag;
		}


		/**
		 * 获取商品列表
		 * 
		 * @return mapProductList value 类型为:std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> 
		 * 
		 */
		 const std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> &  GetProductList() const {
				return mapProductList;
		}


		/**
		 * 获取商品列表
		 * 
		 * @return mapProductList value 类型为:std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> 
		 * 
		 */
		 std::map<uint64_t,icson::deal::shoppingcart::bo::CShoppingcartProduct> &  GetProductList() {
				return mapProductList;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cProductList_u
		 *  
		 * 
		 */
		 void  SetProductList_u( const uint8_t& sVal){
				cProductList_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cProductList_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetProductList_u() const {
				return cProductList_u;
		}

		virtual bool Serialize(CByteStreamNetwork& bs){
		
			uint32_t dwMyLen = 0;
			if(bs.isStoring()) //for write in buffer
			{
				//can not larger than 1 M.
				CByteStreamNetwork bsDummy(NULL, 1024 * 1024, false);
				//bsDummy for precheck the xo size...
				bsDummy.isStoring(true);
				Serialize_i(bsDummy);
				dwMyLen = bsDummy.getWrittenLength();
				bs & dwMyLen;
				Serialize_i(bs);
			}
			else
			{    //for read from buffer
				bs & dwMyLen;
				uint32_t dwReadedLen = bs.getReadLength();
				Serialize_i(bs);
				dwReadedLen = bs.getReadLength() - dwReadedLen;
				// dwReadedLen for the size of xo
				if( dwReadedLen > dwMyLen ){
					return false;
				}
				//go through the unwanted mem position...
				bs.goForward( dwMyLen - dwReadedLen );
			}

			return bs.isGood();
		}

		bool Serialize_i(CByteStreamNetwork& bsTmp){

			bsTmp & dwVersion; // 序列化协议版本号 类型为uint32_t
			bsTmp & cVersion_u; // 序列化 类型为uint8_t
			bsTmp & ddwUserId; // 序列化用户易迅ID 类型为uint64_t
			bsTmp & cUserId_u; // 序列化 类型为uint8_t
			bsTmp & mapProductList; // 序列化商品列表 类型为Map
			bsTmp & cProductList_u; // 序列化 类型为uint8_t
			return bsTmp.isGood();
		}

		const char* GetLastErrMsg() const{
			return m_sLastErrMsg.c_str();
		}

		bool VerifyShoppingcartObject(){

			if(!IsVersionSet()){
				m_sLastErrMsg = "Miss Param:Version";
				return false;
			}

			if(!IsUserIdSet()){
				m_sLastErrMsg = "Miss Param:userId";
				return false;
			}

			if(!IsProductListSet()){
				m_sLastErrMsg = "Miss Param:productList";
				return false;
			}
			return true;
		}

		void DumpData(std::ostream& oss) const{
		
			oss<<"[dwVersion:"<<dwVersion<<"] ";
			oss<<"[cVersion_u:"<<(int)cVersion_u<<"] ";
			oss<<"[ddwUserId:"<<ddwUserId<<"] ";
			oss<<"[cUserId_u:"<<(int)cUserId_u<<"] ";
		//嵌套内容有错误，建议使用dumpDataTree方法，复杂数据格式更直观！
			oss<<"[cProductList_u:"<<(int)cProductList_u<<"] ";
		
		}

		// codydeng提供,非常好的dump方法 ^-^  。。。。。
		template<typename T>
		T & DumpPlusData(T& oss){
			oss<<"dwVersion:"<<dwVersion;
			oss<<"cVersion_u:"<<cVersion_u;
			oss<<"ddwUserId:"<<ddwUserId;
			oss<<"cUserId_u:"<<cUserId_u;
			oss<<"mapProductList:"<<mapProductList;
			oss<<"cProductList_u:"<<cProductList_u;
			return oss;
		}

		// wileywang提供,树形dump方法 ^-^  。。。。。
		void DumpDataTree(std::ostream& os, int ident = 0)const {
			g_pprint(os, "dwVersion", dwVersion, ident);
			g_pprint(os, "cVersion_u", cVersion_u, ident);
			g_pprint(os, "ddwUserId", ddwUserId, ident);
			g_pprint(os, "cUserId_u", cUserId_u, ident);
			g_pprint(os, "mapProductList", mapProductList, ident);
			g_pprint(os, "cProductList_u", cProductList_u, ident);
		}
		
		//提供ToString借口，默认为DumpData格式，请按需要进行修改
		std::string ToString() const{
			std::stringstream ss;
			DumpData(ss);
			return ss.str();
		}

/**
 ********************以下信息是每个版本的字段********************
 */

};

}
}
}
}

#endif /* ICSON_DEAL_SHOPPINGCART_BO_CSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H */
